package com.mobilnaElka.models.search;

import java.util.*;

public class HTMLCreator {


	private String out = "";

	private Map<String, String> valuesToShow;

	public void write() {

		out += (""
				+ "<html>"
				+ "<head>"
				+ "<meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\" />"
				+ "</head>" + "<body>");

		if (!valuesToShow.isEmpty()) {
			Iterator<String> it = valuesToShow.keySet().iterator();
			while (it.hasNext()) {
				String key = it.next();
				if (key.equals(Consts.IMAGE)) {
					out += "<img src=\"" + valuesToShow.get(key) + "\" width=\"100\" />";
				} else if (key.equals(Consts.E_MAIL)){
					writeP(key + ": <u><i>" + valuesToShow.get(key) + "</i></u>");
				} else {
					writeP(key + ": " + valuesToShow.get(key));
				}
			}
		}

		out += ("</body></html>");

	}

	private void writeP(String str) {
		out += ("<p>" + str + "</p>");
	}

	public void putValues(Map<String, String> currValues) {
		valuesToShow = currValues;
	}

	public String getText() {
		return out;
	}
}
